//
//  likeViewController.m
//  Protect -A
//
//  Created by 付剑英 on 16/6/15.
//  Copyright © 2016年 付剑英. All rights reserved.
//

#import "likeViewController.h"
#import "baseCollection.h"
#import "LikeLayout.h"
#import "FirstCollectionCell.h"
#import "SecondCollectionCell.h"
#import "FirstReusableView.h"
#import "APPTools.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
@interface likeViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,retain)baseCollection *collection;

@end

@implementation likeViewController


//内存管理

- (void)dealloc{
    [_collection release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createCollection];
    self.navigationItem.title = @"图库";
}


#pragma mark - ------------ 解析数据---------------

-(void)datahandler{



}





#pragma mark - ------------ 创建collectionview ---------------

- (void)createCollection{
    
    //设置每个分区内置大小
    LikeLayout *layout = [[LikeLayout alloc]init];
   // layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    
    self.collection = [[baseCollection alloc]initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:layout];
    self.collection.backgroundColor = [UIColor whiteColor];
    self.collection.delegate = self;
    self.collection.dataSource = self;
    [self.collection registerClass:[FirstCollectionCell class] forCellWithReuseIdentifier:@"pool1"];
    [self.collection registerClass:[FirstReusableView class]forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
    [self.view addSubview:self.collection];
    
}

#pragma mark - ------------ 按分区返回item个数 ---------------

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    if (section == 0) {
        return 4;
    }else if (section == 1){
        return 5;
    }else if (section == 2){
        return 4;
    }
    else{
        return 7;
    }
}

#pragma mark - ------------ 返回3分区 ---------------

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 4;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
   
    FirstCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"pool1" forIndexPath:indexPath];

    return cell;
}


- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{


    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
        FirstReusableView *header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"header" forIndexPath:indexPath];
       
        
        return header;
        
        
    }
    
    return nil;
}










- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
